#define NOT_EXISTING_DATABASE

namespace DataModels.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitialRebuild : DbMigration
    {
#if NOT_EXISTING_DATABASE
        public override void Up()
        {
            CreateTable(
                "dbo.AccessLevels",
                c => new
                    {
                        AccessID = c.Int(nullable: false),
                        AccessName = c.String(maxLength: 100),
                    })
                .PrimaryKey(t => t.AccessID);
            
            CreateTable(
                "dbo.ANCForm_HudhurioLaKwanza",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_2a = c.Int(nullable: false),
                        C_2b = c.Int(nullable: false),
                        C_2c = c.Int(nullable: false),
                        C_2d = c.Int(nullable: false),
                        C_2e = c.Int(nullable: false),
                        C_2f = c.Int(nullable: false),
                        C_2g = c.Int(nullable: false),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.ANCFormMetadata",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        InputMethodId = c.Int(nullable: false),
                        TimeReceived = c.DateTime(nullable: false),
                        Sender = c.String(maxLength: 255),
                        SenderPhoneNumber = c.String(maxLength: 50),
                        TextMessage = c.String(maxLength: 1000),
                        MoreInformation = c.String(maxLength: 1000),
                        PreviousReportId = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.DataInputMethod", t => t.InputMethodId, cascadeDelete: true)
                .Index(t => t.InputMethodId);
            
            CreateTable(
                "dbo.ANCForm_Malaria",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_6a = c.Int(nullable: false),
                        C_6b = c.Int(nullable: false),
                        C_6c = c.Int(nullable: false),
                        C_6d = c.Int(nullable: false),
                        C_6e = c.Int(nullable: false),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.ANCForm",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_1 = c.Int(),
                        C_3 = c.Int(),
                        C_7 = c.Int(),
                        C_8 = c.Int(),
                        C_9 = c.Int(),
                        C_10 = c.Int(),
                        HudhurioLaKwanza_2id = c.Int(),
                        VidokezoVyaHatari_4id = c.Int(),
                        PMTCT_5id = c.Int(),
                        Malaria_6id = c.Int(),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCForm_HudhurioLaKwanza", t => t.HudhurioLaKwanza_2id)
                .ForeignKey("dbo.ANCForm_Malaria", t => t.Malaria_6id)
                .ForeignKey("dbo.ANCForm_PMTCT", t => t.PMTCT_5id)
                .ForeignKey("dbo.ANCForm_VidokezoVyaHatari", t => t.VidokezoVyaHatari_4id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.HudhurioLaKwanza_2id)
                .Index(t => t.VidokezoVyaHatari_4id)
                .Index(t => t.PMTCT_5id)
                .Index(t => t.Malaria_6id)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.ANCForm_PMTCT",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_5a = c.Int(nullable: false),
                        C_5b = c.Int(nullable: false),
                        C_5c = c.Int(nullable: false),
                        C_5d = c.Int(nullable: false),
                        C_5e = c.Int(nullable: false),
                        C_5f = c.Int(nullable: false),
                        C_5g = c.Int(nullable: false),
                        C_5h = c.Int(nullable: false),
                        C_5i = c.Int(nullable: false),
                        C_5j = c.Int(nullable: false),
                        C_5k = c.Int(nullable: false),
                        C_5l = c.Int(nullable: false),
                        C_5m = c.Int(nullable: false),
                        C_5n = c.Int(nullable: false),
                        C_5o = c.Int(nullable: false),
                        C_5p = c.Int(nullable: false),
                        C_5q = c.Int(nullable: false),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.Facilities",
                c => new
                    {
                        FacCode = c.String(nullable: false, maxLength: 50, unicode: false),
                        FacName = c.String(nullable: false, maxLength: 250),
                        FacShortName = c.String(maxLength: 250),
                        Region = c.Int(nullable: false),
                        District = c.Int(nullable: false),
                        Latitude = c.Decimal(precision: 18, scale: 2),
                        Longitude = c.Decimal(precision: 18, scale: 2),
                        RegistryId = c.String(maxLength: 10),
                        PMTCT = c.Boolean(),
                        LD = c.Boolean(),
                        PMTCTYear = c.Int(),
                        PMTCTPeriod = c.Int(),
                        LDYear = c.Int(),
                        LDPeriod = c.Int(),
                        Description = c.String(maxLength: 1000),
                        Address = c.String(maxLength: 1000),
                        PrincipalContact = c.String(maxLength: 1000),
                        Status = c.Int(),
                        Remarks = c.String(maxLength: 1000),
                        ANCStartDate = c.DateTime(),
                        LDStartDate = c.DateTime(),
                        HEIDStartDate = c.DateTime(),
                        ANC = c.Boolean(),
                        HEID = c.Boolean(),
                        PMTCTStartDate = c.DateTime(),
                        Prophylaxis = c.Boolean(),
                        ProphylaxisStartDate = c.DateTime(),
                        ActiveDate = c.DateTime(),
                        InactiveDate = c.DateTime(),
                        Trained = c.Boolean(),
                        FacilityType = c.Int(nullable: false),
                        InternalName = c.String(maxLength: 250),
                        ProvideDBS = c.Boolean(nullable: false),
                        DBSStartDate = c.DateTime(),
                        Activated = c.Boolean(),
                        CreateDate = c.DateTime(),
                        CreatedByUser = c.Int(),
                        UpdateDate = c.DateTime(),
                        UpdatedByUser = c.Int(),
                        SupportingPartnerId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.FacCode)
                .ForeignKey("dbo.District", t => t.District, cascadeDelete: true)
                .ForeignKey("dbo.FacilityType", t => t.FacilityType, cascadeDelete: true)
                .ForeignKey("dbo.SupportingPartners", t => t.SupportingPartnerId, cascadeDelete: true)
                .Index(t => t.District)
                .Index(t => t.FacilityType)
                .Index(t => t.SupportingPartnerId);
            
            CreateTable(
                "dbo.ANCForm_VidokezoVyaHatari",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_4a = c.Int(nullable: false),
                        C_4b = c.Int(nullable: false),
                        C_4c = c.Int(nullable: false),
                        C_4d = c.Int(nullable: false),
                        C_4e = c.Int(nullable: false),
                        C_4f = c.Int(nullable: false),
                        C_4g = c.Int(nullable: false),
                        C_4h = c.Int(nullable: false),
                        C_4i = c.Int(nullable: false),
                        C_4j = c.Int(nullable: false),
                        C_4k = c.Int(nullable: false),
                        C_4l = c.Int(nullable: false),
                        C_4m = c.Int(nullable: false),
                        C_4n = c.Int(nullable: false),
                        C_4o = c.Int(nullable: false),
                        C_4p = c.Int(nullable: false),
                        C_4q = c.Int(nullable: false),
                        C_4r = c.Int(nullable: false),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.AutoReminderFacilities",
                c => new
                    {
                        FacilityCode = c.String(nullable: false, maxLength: 50, unicode: false),
                    })
                .PrimaryKey(t => t.FacilityCode)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.District",
                c => new
                    {
                        DistrictNo = c.Int(nullable: false),
                        District = c.String(nullable: false, maxLength: 50),
                        RegionNo = c.Int(nullable: false),
                        DistrictCode = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.DistrictNo)
                .ForeignKey("dbo.Region", t => t.RegionNo, cascadeDelete: true)
                .Index(t => t.RegionNo);
            
            CreateTable(
                "dbo.AutoReminderDistricts",
                c => new
                    {
                        DistrictId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.DistrictId)
                .ForeignKey("dbo.District", t => t.DistrictId)
                .Index(t => t.DistrictId);
            
            CreateTable(
                "dbo.Region",
                c => new
                    {
                        RegionNo = c.Int(nullable: false, identity: true),
                        RegionName = c.String(nullable: false, maxLength: 50),
                        RegionCode = c.String(nullable: false, maxLength: 50),
                    })
                .PrimaryKey(t => t.RegionNo);
            
            CreateTable(
                "dbo.AutoReminderRegions",
                c => new
                    {
                        RegionId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.RegionId)
                .ForeignKey("dbo.Region", t => t.RegionId)
                .Index(t => t.RegionId);
            
            CreateTable(
                "dbo.ExpectedReports",
                c => new
                    {
                        FacCode = c.String(nullable: false, maxLength: 50, unicode: false),
                        ReportID = c.Int(nullable: false),
                        ReportingStartDate = c.DateTime(),
                        DirectEntry = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => new { t.FacCode, t.ReportID })
                .ForeignKey("dbo.Facilities", t => t.FacCode, cascadeDelete: true)
                .ForeignKey("dbo.Report", t => t.ReportID, cascadeDelete: true)
                .Index(t => t.FacCode)
                .Index(t => t.ReportID);
            
            CreateTable(
                "dbo.Report",
                c => new
                    {
                        RepID = c.Int(nullable: false, identity: true),
                        ReportName = c.String(maxLength: 250),
                        RepVersion = c.String(maxLength: 50),
                        RepTemplate = c.String(maxLength: 200),
                        Description = c.String(maxLength: 1000),
                        Comments = c.String(maxLength: 1000),
                        UsedAsView = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.RepID);
            
            CreateTable(
                "dbo.AutoReminderReportMessageTemplates",
                c => new
                    {
                        ReportId = c.Int(nullable: false),
                        MessageTemplate = c.String(nullable: false, maxLength: 1000),
                        EnableAutoReminder = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.ReportId)
                .ForeignKey("dbo.Report", t => t.ReportId)
                .Index(t => t.ReportId);
            
            CreateTable(
                "dbo.ReceivedSMs",
                c => new
                    {
                        ReceivedSMSNo = c.Int(nullable: false, identity: true),
                        SenderNum = c.String(nullable: false, maxLength: 100),
                        TxtDetails = c.String(nullable: false, maxLength: 999),
                        DateReceived = c.DateTime(),
                        Processed = c.Boolean(),
                        FacCode = c.String(nullable: false, maxLength: 50, unicode: false),
                        Year = c.Int(),
                        Period = c.Int(),
                        RepID = c.Int(),
                        ReportDate = c.DateTime(),
                        Comments = c.String(maxLength: 1000),
                    })
                .PrimaryKey(t => t.ReceivedSMSNo)
                .ForeignKey("dbo.Facilities", t => t.FacCode, cascadeDelete: true)
                .ForeignKey("dbo.Report", t => t.RepID)
                .Index(t => t.FacCode)
                .Index(t => t.RepID);
            
            CreateTable(
                "dbo.ReportData",
                c => new
                    {
                        SID = c.Int(nullable: false, identity: true),
                        ReceivedSMSNo = c.Int(),
                        RepID = c.Int(),
                        DataPosition = c.Int(),
                        Data = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.SID)
                .ForeignKey("dbo.ReceivedSMs", t => t.ReceivedSMSNo)
                .ForeignKey("dbo.Report", t => t.RepID)
                .Index(t => t.ReceivedSMSNo)
                .Index(t => t.RepID);
            
            CreateTable(
                "dbo.ReportBusinessRules",
                c => new
                    {
                        BRNo = c.Int(nullable: false, identity: true),
                        RepID = c.Int(),
                        MeasurePosNo = c.Int(nullable: false),
                        RuleDescription = c.String(nullable: false, maxLength: 1000),
                        Action = c.Int(nullable: false),
                        ComparedToOrderPos = c.String(maxLength: 50),
                        ComparisonType = c.Int(),
                        Multicomparison = c.Boolean(),
                    })
                .PrimaryKey(t => t.BRNo)
                .ForeignKey("dbo.Report", t => t.RepID)
                .Index(t => t.RepID);
            
            CreateTable(
                "dbo.ReportDataLocations",
                c => new
                    {
                        MeasureNo = c.Int(nullable: false, identity: true),
                        RepID = c.Int(nullable: false),
                        DataDescription = c.String(nullable: false, maxLength: 200),
                        DataPosition = c.Int(nullable: false),
                        DataType = c.String(nullable: false, maxLength: 50),
                        ShortCode = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.MeasureNo)
                .ForeignKey("dbo.Report", t => t.RepID, cascadeDelete: true)
                .Index(t => t.RepID);
            
            CreateTable(
                "dbo.SMSReminderTracker",
                c => new
                    {
                        FacCode = c.String(nullable: false, maxLength: 50, unicode: false),
                        Year = c.Int(nullable: false),
                        Period = c.Int(nullable: false),
                        ReportID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.FacCode, t.Year, t.Period, t.ReportID })
                .ForeignKey("dbo.Facilities", t => t.FacCode, cascadeDelete: true)
                .ForeignKey("dbo.Report", t => t.ReportID, cascadeDelete: true)
                .Index(t => t.FacCode)
                .Index(t => t.ReportID);
            
            CreateTable(
                "dbo.FacilityType",
                c => new
                    {
                        TypeId = c.Int(nullable: false, identity: true),
                        TypeName = c.String(nullable: false, maxLength: 250),
                        TypeDescription = c.String(maxLength: 1000),
                    })
                .PrimaryKey(t => t.TypeId);
            
            CreateTable(
                "dbo.LDForm_EmOC",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_7a = c.Int(nullable: false),
                        C_7b = c.Int(nullable: false),
                        C_7c = c.Int(nullable: false),
                        C_7d = c.Int(nullable: false),
                        C_7e = c.Int(nullable: false),
                        C_7f = c.Int(nullable: false),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.LDForms",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_1 = c.Int(),
                        C_5 = c.Int(),
                        C_12 = c.Int(),
                        C_13 = c.Int(),
                        C_14 = c.Int(),
                        TaarifaYaWaliojifungua_2id = c.Int(),
                        NjiaYaKujifungua_3id = c.Int(),
                        MatatizoKablaYaKujifungua_4id = c.Int(),
                        MatatizoBaadaYaKujifungua_6id = c.Int(),
                        EmOC_7id = c.Int(),
                        PMTCT_8id = c.Int(),
                        WatotoWaliozaliwaMmoja_9id = c.Int(),
                        WatotoWaliozaliwaMapacha_10id = c.Int(),
                        WatotoWaliosaidiwaKupumua_11id = c.Int(),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .ForeignKey("dbo.LDForm_EmOC", t => t.EmOC_7id)
                .ForeignKey("dbo.LDForm_MatatizoBaadaYaKujifungua", t => t.MatatizoBaadaYaKujifungua_6id)
                .ForeignKey("dbo.LDForm_MatatizoKablaYaKujifungua", t => t.MatatizoKablaYaKujifungua_4id)
                .ForeignKey("dbo.LDForm_NjiaYaKujifungua", t => t.NjiaYaKujifungua_3id)
                .ForeignKey("dbo.LDForm_PMTCT", t => t.PMTCT_8id)
                .ForeignKey("dbo.LDForm_TaarifaYaWaliojifungua", t => t.TaarifaYaWaliojifungua_2id)
                .ForeignKey("dbo.LDForm_WatotoWaliosaidiwaKupumua", t => t.WatotoWaliosaidiwaKupumua_11id)
                .ForeignKey("dbo.LDForm_WatotoWaliozaliwaMapacha", t => t.WatotoWaliozaliwaMapacha_10id)
                .ForeignKey("dbo.LDForm_WatotoWaliozaliwaMmoja", t => t.WatotoWaliozaliwaMmoja_9id)
                .Index(t => t.TaarifaYaWaliojifungua_2id)
                .Index(t => t.NjiaYaKujifungua_3id)
                .Index(t => t.MatatizoKablaYaKujifungua_4id)
                .Index(t => t.MatatizoBaadaYaKujifungua_6id)
                .Index(t => t.EmOC_7id)
                .Index(t => t.PMTCT_8id)
                .Index(t => t.WatotoWaliozaliwaMmoja_9id)
                .Index(t => t.WatotoWaliozaliwaMapacha_10id)
                .Index(t => t.WatotoWaliosaidiwaKupumua_11id)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.LDForm_MatatizoBaadaYaKujifungua",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_6a = c.Int(nullable: false),
                        C_6b = c.Int(nullable: false),
                        C_6c = c.Int(nullable: false),
                        C_6d = c.Int(nullable: false),
                        C_6e = c.Int(nullable: false),
                        C_6f = c.Int(nullable: false),
                        C_6g = c.Int(nullable: false),
                        C_6h = c.Int(nullable: false),
                        C_6i = c.Int(nullable: false),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.LDForm_MatatizoKablaYaKujifungua",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_4a = c.Int(nullable: false),
                        C_4b = c.Int(nullable: false),
                        C_4c = c.Int(nullable: false),
                        C_4d = c.Int(nullable: false),
                        C_4e = c.Int(nullable: false),
                        C_4f = c.Int(nullable: false),
                        C_4g = c.Int(nullable: false),
                        C_4h = c.Int(nullable: false),
                        C_4i = c.Int(nullable: false),
                        C_4j = c.Int(nullable: false),
                        C_4k = c.Int(nullable: false),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.LDForm_NjiaYaKujifungua",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_3a = c.Int(nullable: false),
                        C_3b = c.Int(nullable: false),
                        C_3c = c.Int(nullable: false),
                        C_3d = c.Int(nullable: false),
                        C_3e = c.Int(nullable: false),
                        C_3f = c.Int(nullable: false),
                        C_3g = c.Int(nullable: false),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.LDForm_PMTCT",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_8a = c.Int(nullable: false),
                        C_8b = c.Int(nullable: false),
                        C_8c = c.Int(nullable: false),
                        C_8d = c.Int(nullable: false),
                        C_8e = c.Int(nullable: false),
                        C_8f = c.Int(nullable: false),
                        C_8g = c.Int(nullable: false),
                        C_8h = c.Int(nullable: false),
                        C_8i = c.Int(nullable: false),
                        C_8j = c.Int(nullable: false),
                        C_8k = c.Int(nullable: false),
                        C_8l = c.Int(nullable: false),
                        C_8m = c.Int(nullable: false),
                        C_8n = c.Int(nullable: false),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.LDForm_TaarifaYaWaliojifungua",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_2a = c.Int(nullable: false),
                        C_2b = c.Int(nullable: false),
                        C_2c = c.Int(nullable: false),
                        C_2d = c.Int(nullable: false),
                        C_2e = c.Int(nullable: false),
                        C_2f = c.Int(nullable: false),
                        C_2g = c.Int(nullable: false),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.LDForm_WatotoWaliosaidiwaKupumua",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_11a = c.Int(nullable: false),
                        C_11b = c.Int(nullable: false),
                        C_11c = c.Int(nullable: false),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.LDForm_WatotoWaliozaliwaMapacha",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_10a = c.Int(nullable: false),
                        C_10b = c.Int(nullable: false),
                        C_10c = c.Int(nullable: false),
                        C_10d = c.Int(nullable: false),
                        C_10e = c.Int(nullable: false),
                        C_10f = c.Int(nullable: false),
                        C_10g = c.Int(nullable: false),
                        C_10h = c.Int(nullable: false),
                        C_10i = c.Int(nullable: false),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.LDForm_WatotoWaliozaliwaMmoja",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        C_9a = c.Int(nullable: false),
                        C_9b = c.Int(nullable: false),
                        C_9c = c.Int(nullable: false),
                        C_9d = c.Int(nullable: false),
                        C_9e = c.Int(nullable: false),
                        C_9f = c.Int(nullable: false),
                        C_9g = c.Int(nullable: false),
                        C_9h = c.Int(nullable: false),
                        C_9i = c.Int(nullable: false),
                        MetadataId = c.Int(nullable: false),
                        FacilityCode = c.String(maxLength: 50, unicode: false),
                        ReportDate = c.DateTime(nullable: false),
                        LessThan20 = c.Boolean(nullable: false),
                        Comments = c.String(maxLength: 1000),
                        Year = c.Int(),
                        Month = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ANCFormMetadata", t => t.MetadataId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.MetadataId)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.OtherSystemsFacilityDetails",
                c => new
                    {
                        SystemId = c.Int(nullable: false),
                        InternalFacilityCode = c.String(nullable: false, maxLength: 50, unicode: false),
                        FacilityCode = c.String(nullable: false, maxLength: 50),
                        FacilityName = c.String(nullable: false, maxLength: 255),
                        DistrictName = c.String(nullable: false, maxLength: 255),
                        RegionName = c.String(nullable: false, maxLength: 255),
                        HTC_ServiceType = c.String(maxLength: 10),
                        Care_ServiceType = c.String(maxLength: 10),
                        FN_ServiceType = c.String(maxLength: 10),
                        TB_HIV_ServiceType = c.String(maxLength: 10),
                        TX_ServiceType = c.String(maxLength: 10),
                        PMTCT_ServiceType = c.String(maxLength: 10),
                        HRH_ServiceType = c.String(maxLength: 10),
                        LAB_ServiceType = c.String(maxLength: 10),
                        VMMC_ServiceType = c.String(maxLength: 10),
                        GPY_ServiceType = c.String(maxLength: 10),
                        KP_ServiceType = c.String(maxLength: 10),
                        OVC_ServiceType = c.String(maxLength: 10),
                        FPINT_ServiceType = c.String(maxLength: 10),
                    })
                .PrimaryKey(t => new { t.SystemId, t.InternalFacilityCode })
                .ForeignKey("dbo.Facilities", t => t.InternalFacilityCode, cascadeDelete: true)
                .ForeignKey("dbo.OtherSystems", t => t.SystemId, cascadeDelete: true)
                .Index(t => t.SystemId)
                .Index(t => t.InternalFacilityCode);
            
            CreateTable(
                "dbo.OtherSystems",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 255),
                        Description = c.String(),
                        ProvidesFacilityUniqueIdentifier = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SupportingPartners",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 255),
                        Description = c.String(maxLength: 1000),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CDCTargets",
                c => new
                    {
                        FacilityCode = c.String(nullable: false, maxLength: 50, unicode: false),
                        COPYear = c.String(nullable: false, maxLength: 4),
                        HTC_NGI_Direct = c.Boolean(),
                        HTC_ServiceType = c.String(maxLength: 10),
                        HTC_TST_MaleLT1 = c.Int(),
                        HTC_TST_FemaleLT1 = c.Int(),
                        HTC_TST_MaleBT1_4 = c.Int(),
                        HTC_TST_FemaleBT1_4 = c.Int(),
                        HTC_TST_MaleBT5_9 = c.Int(),
                        HTC_TST_FemaleBT5_9 = c.Int(),
                        HTC_TST_MaleBT10_14 = c.Int(),
                        HTC_TST_FemaleBT10_14 = c.Int(),
                        HTC_TST_MaleBT15_19 = c.Int(),
                        HTC_TST_FemaleBT15_19 = c.Int(),
                        HTC_TST_MaleBT20_24 = c.Int(),
                        HTC_TST_FemaleBT20_24 = c.Int(),
                        HTC_TST_MaleBT25_49 = c.Int(),
                        HTC_TST_FemaleBT25_49 = c.Int(),
                        HTC_TST_MaleGT50 = c.Int(),
                        HTC_TST_FemaleGT50 = c.Int(),
                        HTC_TST_ByTestResultPositive = c.Int(),
                        HTC_TST_ByTestResultNegative = c.Int(),
                        HTC_TST_ByCoupleIndividualPositive = c.Int(),
                        HTC_TST_ByCoupleIndividualNegative = c.Int(),
                        HTC_TST_ByCoupleCouplePositive = c.Int(),
                        HTC_TST_ByCoupleCoupleNegative = c.Int(),
                        TZ_CARE_NGI_Direct = c.Boolean(),
                        TZ_CARE_ServiceType = c.String(maxLength: 10),
                        C21D_MaleLT15 = c.Int(),
                        C21D_FemaleLT15 = c.Int(),
                        C21D_MaleGT15 = c.Int(),
                        C21D_FemaleGT15 = c.Int(),
                        TZ_CARE_MaleLT1 = c.Int(),
                        TZ_CARE_FemaleLT1 = c.Int(),
                        TZ_CARE_MaleBT1_4 = c.Int(),
                        TZ_CARE_FemaleBT1_4 = c.Int(),
                        TZ_CARE_MaleBT5_9 = c.Int(),
                        TZ_CARE_FemaleBT5_9 = c.Int(),
                        TZ_CARE_MaleBT10_14 = c.Int(),
                        TZ_CARE_FemaleBT10_14 = c.Int(),
                        TZ_CARE_MaleBT15_19 = c.Int(),
                        TZ_CARE_FemaleBT15_19 = c.Int(),
                        TZ_CARE_MaleBT20_24 = c.Int(),
                        TZ_CARE_FemaleBT20_24 = c.Int(),
                        TZ_CARE_MaleBT25_49 = c.Int(),
                        TZ_CARE_FemaleBT25_49 = c.Int(),
                        TZ_CARE_MaleGT50 = c.Int(),
                        TZ_CARE_FemaleGT50 = c.Int(),
                        TZ_NUT_MaleLT1 = c.Int(),
                        TZ_NUT_FemaleLT1 = c.Int(),
                        TZ_NUT_MaleBT1_4 = c.Int(),
                        TZ_NUT_FemaleBT1_4 = c.Int(),
                        TZ_NUT_MaleBT5_14 = c.Int(),
                        TZ_NUT_FemaleBT5_14 = c.Int(),
                        TZ_NUT_MaleBT15_17 = c.Int(),
                        TZ_NUT_FemaleBT15_17 = c.Int(),
                        TZ_NUT_MaleGT18 = c.Int(),
                        TZ_NUT_FemaleGT18 = c.Int(),
                        TZ_ECON_MaleLT1 = c.Int(),
                        TZ_ECON_FemaleLT1 = c.Int(),
                        TZ_ECON_MaleBT1_4 = c.Int(),
                        TZ_ECON_FemaleBT1_4 = c.Int(),
                        TZ_ECON_MaleBT5_9 = c.Int(),
                        TZ_ECON_FemaleBT5_9 = c.Int(),
                        TZ_ECON_MaleBT10_14 = c.Int(),
                        TZ_ECON_FemaleBT10_14 = c.Int(),
                        TZ_ECON_MaleBT15_19 = c.Int(),
                        TZ_ECON_FemaleBT15_19 = c.Int(),
                        TZ_ECON_MaleBT20_24 = c.Int(),
                        TZ_ECON_FemaleBT20_24 = c.Int(),
                        TZ_ECON_MaleBT25_49 = c.Int(),
                        TZ_ECON_FemaleBT25_49 = c.Int(),
                        TZ_ECON_MaleBT50_64 = c.Int(),
                        TZ_ECON_FemaleBT50_64 = c.Int(),
                        TZ_ECON_MaleGT65 = c.Int(),
                        TZ_ECON_FemaleGT65 = c.Int(),
                        FN_THER_ServiceType = c.String(maxLength: 10),
                        FN_THER_Num = c.Int(),
                        FN_THER_Denom = c.Int(),
                        TB_HIV_NGI_Direct = c.Boolean(),
                        TB_HIV_ServiceType = c.String(maxLength: 10),
                        TB_HIV_Num = c.Int(),
                        TB_HIV_Denom = c.Int(),
                        TX_NGI_Direct = c.Boolean(),
                        TX_ServiceType = c.String(maxLength: 10),
                        TX_NEW_MaleLT1 = c.Int(),
                        TX_NEW_FemaleLT1 = c.Int(),
                        TX_NEW_MaleLT15 = c.Int(),
                        TX_NEW_FemaleLT15 = c.Int(),
                        TX_NEW_MaleGT15 = c.Int(),
                        TX_NEW_FemaleGT15 = c.Int(),
                        TX_NEW_PregnantWomen = c.Int(),
                        TX_CURR_MaleLT1 = c.Int(),
                        TX_CURR_FemaleLT1 = c.Int(),
                        TX_CURR_MaleLT15 = c.Int(),
                        TX_CURR_FemaleLT15 = c.Int(),
                        TX_CURR_MaleGT15 = c.Int(),
                        TX_CURR_FemaleGT15 = c.Int(),
                        TX_RET_Num_0_4 = c.Int(),
                        TX_RET_Num_5_15 = c.Int(),
                        TX_RET_Num_LT15 = c.Int(),
                        TX_RET_Num_PregnantWomen = c.Int(),
                        TX_RET_Num_BreastFeeding = c.Int(),
                        TX_RET_Denom_0_4 = c.Int(),
                        TX_RET_Denom_5_15 = c.Int(),
                        TX_RET_Denom_LT15 = c.Int(),
                        TX_RET_Denom_PregnantWomen = c.Int(),
                        TX_RET_Denom_BreastFeeding = c.Int(),
                        PMTCT_NGI_Direct = c.Boolean(),
                        PMTCT_ServiceType = c.String(maxLength: 10),
                        PMTCT_STAT_TestedPositive = c.Int(),
                        PMTCT_STAT_TestedNegative = c.Int(),
                        PMTCT_KnownPositive = c.Int(),
                        PMTCT_NewClients = c.Int(),
                        PMTCT_ARV_OptionB_NewOnART = c.Int(),
                        PMTCT_ARV_OptionB_AlreadyOnART = c.Int(),
                        PMTCT_ARV_MaternalAZT = c.Int(),
                        PMTCT_ARV_Denom_PregnantWomenIdentified = c.Int(),
                        PMTCT_EID_TestedLT2 = c.Int(),
                        PMTCT_EID_TestedBT2_12 = c.Int(),
                        PMTCT_EID_TestedPositiveLT2 = c.Int(),
                        PMTCT_EID_TestedPositiveBT2_12 = c.Int(),
                        P13D_ProvideANCServices = c.Boolean(),
                    })
                .PrimaryKey(t => new { t.FacilityCode, t.COPYear })
                .ForeignKey("dbo.Facilities", t => t.FacilityCode, cascadeDelete: true)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.TestingAndCounselingDatas",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        FacilityCode = c.String(nullable: false, maxLength: 50, unicode: false),
                        TimeframeId = c.Int(nullable: false),
                        CounselingAndTestingId = c.Int(nullable: false),
                        UserId = c.Int(),
                        DateCreated = c.DateTime(),
                        TC01_MaleLT15 = c.Int(nullable: false),
                        TC01_MaleGT15 = c.Int(nullable: false),
                        TC01_FemaleLT15 = c.Int(nullable: false),
                        TC01_FemaleGT15 = c.Int(nullable: false),
                        TC02_MaleLT15 = c.Int(nullable: false),
                        TC02_MaleGT15 = c.Int(nullable: false),
                        TC02_FemaleLT15 = c.Int(nullable: false),
                        TC02_FemaleGT15 = c.Int(nullable: false),
                        TC03_MaleLT15 = c.Int(nullable: false),
                        TC03_MaleGT15 = c.Int(nullable: false),
                        TC03_FemaleLT15 = c.Int(nullable: false),
                        TC03_FemaleGT15 = c.Int(nullable: false),
                        TC04_MaleLT15 = c.Int(nullable: false),
                        TC04_MaleGT15 = c.Int(nullable: false),
                        TC04_FemaleLT15 = c.Int(nullable: false),
                        TC04_FemaleGT15 = c.Int(nullable: false),
                        TC05_MaleLT15 = c.Int(nullable: false),
                        TC05_MaleGT15 = c.Int(nullable: false),
                        TC05_FemaleLT15 = c.Int(nullable: false),
                        TC05_FemaleGT15 = c.Int(nullable: false),
                        TC06_MaleLT15 = c.Int(nullable: false),
                        TC06_MaleGT15 = c.Int(nullable: false),
                        TC06_FemaleLT15 = c.Int(nullable: false),
                        TC06_FemaleGT15 = c.Int(nullable: false),
                        TC07_MaleLT15 = c.Int(nullable: false),
                        TC07_MaleGT15 = c.Int(nullable: false),
                        TC07_FemaleLT15 = c.Int(nullable: false),
                        TC07_FemaleGT15 = c.Int(nullable: false),
                        TC08_MaleLT15 = c.Int(nullable: false),
                        TC08_MaleGT15 = c.Int(nullable: false),
                        TC08_FemaleLT15 = c.Int(nullable: false),
                        TC08_FemaleGT15 = c.Int(nullable: false),
                        TC09_MaleLT15 = c.Int(nullable: false),
                        TC09_MaleGT15 = c.Int(nullable: false),
                        TC09_FemaleLT15 = c.Int(nullable: false),
                        TC09_FemaleGT15 = c.Int(nullable: false),
                        TC10_MaleLT15 = c.Int(nullable: false),
                        TC10_MaleGT15 = c.Int(nullable: false),
                        TC10_FemaleLT15 = c.Int(nullable: false),
                        TC10_FemaleGT15 = c.Int(nullable: false),
                        TC11_MaleLT15 = c.Int(nullable: false),
                        TC11_MaleGT15 = c.Int(nullable: false),
                        TC11_FemaleLT15 = c.Int(nullable: false),
                        TC11_FemaleGT15 = c.Int(nullable: false),
                        TC12_MaleLT15 = c.Int(nullable: false),
                        TC12_MaleGT15 = c.Int(nullable: false),
                        TC12_FemaleLT15 = c.Int(nullable: false),
                        TC12_FemaleGT15 = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.TestingAndCounselings", t => t.CounselingAndTestingId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode, cascadeDelete: true)
                .ForeignKey("dbo.Timeframes", t => t.TimeframeId, cascadeDelete: true)
                .ForeignKey("dbo.Users", t => t.UserId)
                .Index(t => t.FacilityCode)
                .Index(t => t.TimeframeId)
                .Index(t => t.CounselingAndTestingId)
                .Index(t => t.UserId);
            
            CreateTable(
                "dbo.TestingAndCounselings",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 10),
                        Description = c.String(nullable: false, maxLength: 1000),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Timeframes",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(maxLength: 7),
                        Description = c.String(maxLength: 1000),
                        StartTime = c.DateTime(nullable: false),
                        EndTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Users",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Username = c.String(nullable: false, maxLength: 100),
                        FirstName = c.String(nullable: false, maxLength: 100),
                        LastName = c.String(nullable: false, maxLength: 100),
                        Password = c.String(nullable: false, maxLength: 250),
                        EmailAddress = c.String(nullable: false, maxLength: 250),
                        PhoneNumber = c.String(maxLength: 50),
                        AccessLevelID = c.Int(nullable: false),
                        AccessLevelValue = c.String(nullable: false, maxLength: 50),
                        Deleted = c.Boolean(nullable: false),
                        CreateDate = c.DateTime(),
                        CreatedByUser = c.Int(),
                        UpdateDate = c.DateTime(),
                        UpdatedByUser = c.Int(),
                        DeleteDate = c.DateTime(),
                        DeletedByUser = c.Int(),
                        SupportingPartnerId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.AccessLevels", t => t.AccessLevelID, cascadeDelete: true)
                .ForeignKey("dbo.SupportingPartners", t => t.SupportingPartnerId, cascadeDelete: true)
                .Index(t => t.AccessLevelID)
                .Index(t => t.SupportingPartnerId);
            
            CreateTable(
                "dbo.Queries",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 1000),
                        InternalName = c.String(nullable: false, maxLength: 1000),
                        Description = c.String(maxLength: 1000),
                        Definition = c.String(nullable: false),
                        More = c.String(maxLength: 1000),
                        QueryTypeId = c.Int(nullable: false),
                        Deleted = c.Boolean(nullable: false),
                        CreateDate = c.DateTime(nullable: false),
                        CreatedByUserId = c.Int(),
                        UpdateDate = c.DateTime(),
                        UpdatedByUserId = c.Int(),
                        DeleteDate = c.DateTime(),
                        DeletedByUserId = c.Int(),
                        CreateTable = c.Boolean(nullable: false),
                        User_ID = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Users", t => t.CreatedByUserId)
                .ForeignKey("dbo.Users", t => t.DeletedByUserId)
                .ForeignKey("dbo.QueryTypes", t => t.QueryTypeId, cascadeDelete: true)
                .ForeignKey("dbo.Users", t => t.UpdatedByUserId)
                .ForeignKey("dbo.Users", t => t.User_ID)
                .Index(t => t.InternalName, unique: true)
                .Index(t => t.QueryTypeId)
                .Index(t => t.CreatedByUserId)
                .Index(t => t.UpdatedByUserId)
                .Index(t => t.DeletedByUserId)
                .Index(t => t.User_ID);
            
            CreateTable(
                "dbo.QueryCategories",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 1000),
                        Description = c.String(maxLength: 1000),
                        CreateDate = c.DateTime(nullable: false),
                        CreatedByUserId = c.Int(),
                        UpdateDate = c.DateTime(),
                        UpdatedByUserId = c.Int(),
                        User_ID = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Users", t => t.CreatedByUserId)
                .ForeignKey("dbo.Users", t => t.UpdatedByUserId)
                .ForeignKey("dbo.Users", t => t.User_ID)
                .Index(t => t.CreatedByUserId)
                .Index(t => t.UpdatedByUserId)
                .Index(t => t.User_ID);
            
            CreateTable(
                "dbo.QueryParameters",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 200),
                        Description = c.String(nullable: false, maxLength: 1000),
                        ValidationExpression = c.String(nullable: false, maxLength: 1000),
                        DataTypeName = c.String(nullable: false, maxLength: 1000),
                        QueryId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Queries", t => t.QueryId, cascadeDelete: true)
                .Index(t => t.QueryId);
            
            CreateTable(
                "dbo.QueryTypes",
                c => new
                    {
                        QueryTypeId = c.Int(nullable: false),
                        Name = c.String(maxLength: 1000),
                        Description = c.String(maxLength: 1000),
                    })
                .PrimaryKey(t => t.QueryTypeId);
            
            CreateTable(
                "dbo.webpages_Roles",
                c => new
                    {
                        RoleId = c.Int(nullable: false, identity: true),
                        RoleName = c.String(nullable: false, maxLength: 256),
                    })
                .PrimaryKey(t => t.RoleId);
            
            CreateTable(
                "dbo.DataInputMethod",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 255),
                        Description = c.String(maxLength: 1000),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.ApprovedSMSCells",
                c => new
                    {
                        ApprovedCellNo = c.Int(nullable: false, identity: true),
                        CellNum = c.String(maxLength: 250),
                        Name = c.String(maxLength: 250),
                        LangID = c.Int(),
                        SendSMS = c.Boolean(),
                        FacCode = c.String(maxLength: 50),
                        Email = c.String(maxLength: 255),
                        TitleID = c.Int(),
                        CreatedBy = c.Int(),
                        CreateDate = c.DateTime(),
                        UpdatedBy = c.Int(),
                        UpdateDate = c.DateTime(),
                        DeletedBy = c.Int(),
                        DeleteDate = c.DateTime(),
                        Deleted = c.Boolean(),
                    })
                .PrimaryKey(t => t.ApprovedCellNo);
            
            CreateTable(
                "dbo.Assistance",
                c => new
                    {
                        AssistanceID = c.Int(nullable: false, identity: true),
                        ApprovedCellNo = c.Int(nullable: false),
                        FacCode = c.String(maxLength: 50),
                        DistrictID = c.Int(),
                        RegionID = c.Int(),
                    })
                .PrimaryKey(t => t.AssistanceID);
            
            CreateTable(
                "dbo.BlockedNumbers",
                c => new
                    {
                        PhoneNumber = c.String(nullable: false, maxLength: 50),
                    })
                .PrimaryKey(t => t.PhoneNumber);
            
            CreateTable(
                "dbo.CalendarHolidays",
                c => new
                    {
                        CalendarYear = c.Int(nullable: false),
                        HolidayDate = c.String(nullable: false, maxLength: 6),
                        HolidayName = c.String(nullable: false, maxLength: 1000),
                    })
                .PrimaryKey(t => new { t.CalendarYear, t.HolidayDate });
            
            CreateTable(
                "dbo.ComparisonType",
                c => new
                    {
                        ComparisonType1 = c.Int(nullable: false, identity: true),
                        ComparisonSign = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.ComparisonType1);
            
            CreateTable(
                "dbo.ErrMsgSMS",
                c => new
                    {
                        ReceivedSMSNo = c.Int(nullable: false, identity: true),
                        SenderNum = c.String(maxLength: 50),
                        TxtDetails = c.String(maxLength: 1000),
                        DateReceived = c.DateTime(),
                        FacCode = c.String(maxLength: 50),
                        Year = c.Int(),
                        Period = c.Int(),
                        RepID = c.Int(),
                        ErrMsg = c.String(maxLength: 1000),
                        Deleted = c.Boolean(),
                        KnownReportingErrorId = c.Int(),
                    })
                .PrimaryKey(t => t.ReceivedSMSNo)
                .ForeignKey("dbo.KnownReportingErrors", t => t.KnownReportingErrorId)
                .Index(t => t.KnownReportingErrorId);
            
            CreateTable(
                "dbo.KnownReportingErrors",
                c => new
                    {
                        ErrorCode = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 250),
                        Description = c.String(maxLength: 1000),
                    })
                .PrimaryKey(t => t.ErrorCode);
            
            CreateTable(
                "dbo.ExcelTemplateCells",
                c => new
                    {
                        CellID = c.Int(nullable: false, identity: true),
                        SheetID = c.Int(nullable: false),
                        CellRowIndex = c.Int(),
                        CellColumnIndex = c.Int(),
                        IndicatorDataSource = c.String(maxLength: 1000),
                        ColumnHeader = c.String(maxLength: 1000),
                        RowHeader = c.String(maxLength: 1000),
                        ColumnHeaderIndex = c.Int(nullable: false),
                        RowHeaderIndex = c.Int(nullable: false),
                        CellAddress = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.CellID)
                .ForeignKey("dbo.ExcelTemplateSheets", t => t.SheetID, cascadeDelete: true)
                .Index(t => t.SheetID);
            
            CreateTable(
                "dbo.ExcelTemplateCellExtras",
                c => new
                    {
                        ExtrasID = c.Int(nullable: false, identity: true),
                        Extras = c.String(nullable: false, maxLength: 1000),
                        CellID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ExtrasID)
                .ForeignKey("dbo.ExcelTemplateCells", t => t.CellID, cascadeDelete: true)
                .Index(t => t.CellID);
            
            CreateTable(
                "dbo.ExcelTemplateSheets",
                c => new
                    {
                        SheetID = c.Int(nullable: false, identity: true),
                        TemplateSheetName = c.String(maxLength: 1000),
                        OutputSheetName = c.String(maxLength: 1000),
                        OutputsheetNameTemplate = c.String(maxLength: 1000),
                        HasRepetitiveRows = c.Boolean(nullable: false),
                        HasRepetitiveColumns = c.Boolean(nullable: false),
                        FirstRepetitiveColumnCellIndex = c.Int(),
                        FirstRepetitiveRowCellIndex = c.Int(),
                        LastRepetitiveColumnCellIndex = c.Int(),
                        LastRepetitiveRowCellIndex = c.Int(),
                        TemplateID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.SheetID)
                .ForeignKey("dbo.ExcelTemplateReport", t => t.TemplateID, cascadeDelete: true)
                .Index(t => t.TemplateID);
            
            CreateTable(
                "dbo.ExcelTemplateReport",
                c => new
                    {
                        TemplateID = c.Int(nullable: false, identity: true),
                        TemplateName = c.String(maxLength: 1000),
                        Description = c.String(maxLength: 1000),
                        Filename = c.String(maxLength: 1000),
                        MainTemplate = c.Boolean(nullable: false),
                        UsedInSAPR = c.Boolean(nullable: false),
                        UsedInAPR = c.Boolean(nullable: false),
                        CalculatingMethod = c.Int(),
                    })
                .PrimaryKey(t => t.TemplateID);
            
            CreateTable(
                "dbo.Languages",
                c => new
                    {
                        LangID = c.Int(nullable: false),
                        Language = c.String(maxLength: 200),
                    })
                .PrimaryKey(t => t.LangID);
            
            CreateTable(
                "dbo.Translations",
                c => new
                    {
                        TransID = c.Int(nullable: false, identity: true),
                        LangID = c.Int(nullable: false),
                        LabelNo = c.Int(nullable: false),
                        LText = c.String(nullable: false, maxLength: 1000),
                    })
                .PrimaryKey(t => t.TransID)
                .ForeignKey("dbo.Languages", t => t.LangID, cascadeDelete: true)
                .Index(t => t.LangID);
            
            CreateTable(
                "dbo.MergingReports",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        MergeId = c.Int(),
                        DestinationReportId = c.Int(),
                        SourceReportId = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Report", t => t.DestinationReportId)
                .ForeignKey("dbo.ReportMerge", t => t.MergeId)
                .ForeignKey("dbo.Report", t => t.SourceReportId)
                .Index(t => new { t.MergeId, t.DestinationReportId, t.SourceReportId }, unique: true, name: "IX_MergingReports");
            
            CreateTable(
                "dbo.ReportMerge",
                c => new
                    {
                        MergeId = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 250),
                        Description = c.String(maxLength: 1000),
                    })
                .PrimaryKey(t => t.MergeId)
                .Index(t => t.Name, unique: true);
            
            CreateTable(
                "dbo.ReportDataMerging",
                c => new
                    {
                        DataMergeId = c.Int(nullable: false, identity: true),
                        MergeId = c.Int(nullable: false),
                        DestinationIndicator = c.String(nullable: false, maxLength: 250),
                        SourceIndicator = c.String(nullable: false, maxLength: 250),
                        Comments = c.String(maxLength: 1000),
                    })
                .PrimaryKey(t => t.DataMergeId)
                .ForeignKey("dbo.ReportMerge", t => t.MergeId, cascadeDelete: true)
                .Index(t => t.MergeId);
            
            CreateTable(
                "dbo.MobileContryCode",
                c => new
                    {
                        MCC = c.String(nullable: false, maxLength: 128),
                        ISOCode = c.String(nullable: false, maxLength: 3),
                        Country = c.String(maxLength: 2),
                    })
                .PrimaryKey(t => t.MCC);
            
            CreateTable(
                "dbo.MobilePhoneOperators",
                c => new
                    {
                        MCC = c.String(nullable: false, maxLength: 128),
                        MNC = c.String(nullable: false, maxLength: 3),
                        Brand = c.String(maxLength: 100),
                        Operator = c.String(maxLength: 250),
                        Status = c.String(maxLength: 50),
                        Bands_MHz = c.String(maxLength: 250),
                        Notes = c.String(maxLength: 1000),
                    })
                .PrimaryKey(t => new { t.MCC, t.MNC })
                .ForeignKey("dbo.MobileContryCode", t => t.MCC, cascadeDelete: true)
                .Index(t => t.MCC);
            
            CreateTable(
                "dbo.ModemAssociatedCellNumbers",
                c => new
                    {
                        ModemNumberID = c.Int(nullable: false, identity: true),
                        ModemSettingNo = c.Int(nullable: false),
                        AssociatedCellNum = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.ModemNumberID)
                .ForeignKey("dbo.ModemSettings", t => t.ModemSettingNo, cascadeDelete: true)
                .Index(t => t.ModemSettingNo);
            
            CreateTable(
                "dbo.ModemSettings",
                c => new
                    {
                        ModemSettingNo = c.Int(nullable: false, identity: true),
                        ModemName = c.String(maxLength: 50),
                        PortName = c.String(maxLength: 50),
                        BaudRate = c.Int(),
                        DataBits = c.Int(),
                        StopBits = c.Int(),
                        ParityBits = c.String(maxLength: 50),
                        ReadTimeout = c.Int(),
                        WriteTimeout = c.Int(),
                    })
                .PrimaryKey(t => t.ModemSettingNo);
            
            CreateTable(
                "dbo.MTUHA_Reports",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 255),
                        ReleaseDate = c.DateTime(),
                        Description = c.String(maxLength: 1000),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.MTUHA_ReportSections",
                c => new
                    {
                        SectionId = c.Int(nullable: false, identity: true),
                        MTUHAReportId = c.Int(nullable: false),
                        SectionNumber = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 255),
                    })
                .PrimaryKey(t => t.SectionId)
                .ForeignKey("dbo.MTUHA_Reports", t => t.MTUHAReportId, cascadeDelete: true)
                .Index(t => t.MTUHAReportId);
            
            CreateTable(
                "dbo.MTUHA_ReportSectionDetails",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SectionId = c.Int(nullable: false),
                        ShortCode = c.String(nullable: false, maxLength: 10),
                        Name = c.String(nullable: false, maxLength: 255),
                        Description = c.String(maxLength: 1000),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.MTUHA_ReportSections", t => t.SectionId, cascadeDelete: true)
                .Index(t => t.SectionId);
            
            CreateTable(
                "dbo.OptionBPlusFacilities",
                c => new
                    {
                        FacilityCode = c.String(nullable: false, maxLength: 50, unicode: false),
                        DateStarted = c.DateTime(nullable: false),
                        DateTrained = c.DateTime(),
                        HasCTC = c.Boolean(nullable: false),
                        CTCStartDate = c.DateTime(),
                    })
                .PrimaryKey(t => t.FacilityCode)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode)
                .Index(t => t.FacilityCode);
            
            CreateTable(
                "dbo.MessagingLogs",
                c => new
                    {
                        MessagingLogId = c.Int(nullable: false, identity: true),
                        PhoneNumber = c.String(nullable: false, maxLength: 50),
                        MessageBody = c.String(nullable: false, maxLength: 1000),
                        DateSendReceived = c.DateTime(nullable: false),
                        IsMessageSentToUser = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.MessagingLogId)
                .ForeignKey("dbo.OtherSystemUserNumbers", t => t.PhoneNumber, cascadeDelete: true)
                .Index(t => t.PhoneNumber);
            
            CreateTable(
                "dbo.OtherSystemUserNumbers",
                c => new
                    {
                        PhoneNumber = c.String(nullable: false, maxLength: 50),
                    })
                .PrimaryKey(t => t.PhoneNumber);
            
            CreateTable(
                "dbo.PresetCharts",
                c => new
                    {
                        ChartID = c.Int(nullable: false, identity: true),
                        ChartName = c.String(nullable: false, maxLength: 255),
                    })
                .PrimaryKey(t => t.ChartID);
            
            CreateTable(
                "dbo.PresetChartsIndicators",
                c => new
                    {
                        IndicatorID = c.Int(nullable: false, identity: true),
                        ChartID = c.Int(nullable: false),
                        CompositeIndicator = c.Boolean(nullable: false),
                        IndicatorName = c.String(nullable: false, maxLength: 255),
                        IndicatorDefinition = c.String(nullable: false, maxLength: 255),
                    })
                .PrimaryKey(t => t.IndicatorID);
            
            CreateTable(
                "dbo.ReportChartIndicators",
                c => new
                    {
                        ReportIndicatorID = c.Int(nullable: false, identity: true),
                        ReportID = c.Int(nullable: false),
                        ReportDataPosition = c.Int(nullable: false),
                        ReportDataPositionDescription = c.String(nullable: false, maxLength: 255),
                    })
                .PrimaryKey(t => t.ReportIndicatorID);
            
            CreateTable(
                "dbo.SendSMSQueue",
                c => new
                    {
                        SMSSID = c.Int(nullable: false, identity: true),
                        SenderNum = c.String(maxLength: 50),
                        TxtDetails = c.String(maxLength: 1000),
                    })
                .PrimaryKey(t => t.SMSSID);
            
            CreateTable(
                "dbo.SMSLog",
                c => new
                    {
                        SMSIDNo = c.Int(nullable: false, identity: true),
                        SMSType = c.Boolean(),
                        CellNum = c.String(maxLength: 50),
                        Message = c.String(maxLength: 1000),
                        Date = c.DateTime(),
                        ReceivedSMSNo = c.String(maxLength: 50),
                        Processed = c.Boolean(),
                    })
                .PrimaryKey(t => t.SMSIDNo);
            
            CreateTable(
                "dbo.SMSReminders",
                c => new
                    {
                        SMSRID = c.Int(nullable: false, identity: true),
                        SMSDate = c.DateTime(),
                        SMSTime = c.Time(precision: 7),
                    })
                .PrimaryKey(t => t.SMSRID);
            
            CreateTable(
                "dbo.StockStatus",
                c => new
                    {
                        FacCode = c.String(nullable: false, maxLength: 50),
                        RequiredDetermine = c.Int(),
                        RequiredUnigold = c.Int(),
                        RequiredDBS = c.Int(),
                        AvailableDetermine = c.Int(),
                        AvailableUnigold = c.Int(),
                        AvailableDBS = c.Int(),
                        DateReportReceived = c.DateTime(),
                        ReportDate = c.DateTime(),
                        ReportYear = c.Int(),
                        ReportMonth = c.Int(),
                    })
                .PrimaryKey(t => t.FacCode);
            
            CreateTable(
                "dbo.SysSettings",
                c => new
                    {
                        SettingName = c.String(nullable: false, maxLength: 500),
                        SettingValue = c.String(nullable: false, maxLength: 1000),
                    })
                .PrimaryKey(t => t.SettingName);
            
            CreateTable(
                "dbo.webpages_Membership",
                c => new
                    {
                        UserId = c.Int(nullable: false),
                        CreateDate = c.DateTime(),
                        ConfirmationToken = c.String(maxLength: 128),
                        IsConfirmed = c.Boolean(),
                        LastPasswordFailureDate = c.DateTime(),
                        PasswordFailuresSinceLastSuccess = c.Int(nullable: false),
                        Password = c.String(nullable: false, maxLength: 128),
                        PasswordChangedDate = c.DateTime(),
                        PasswordSalt = c.String(nullable: false, maxLength: 128),
                        PasswordVerificationToken = c.String(maxLength: 128),
                        PasswordVerificationTokenExpirationDate = c.DateTime(),
                    })
                .PrimaryKey(t => t.UserId);
            
            CreateTable(
                "dbo.webpages_OAuthMembership",
                c => new
                    {
                        Provider = c.String(nullable: false, maxLength: 30),
                        ProviderUserId = c.String(nullable: false, maxLength: 100),
                        UserId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Provider, t.ProviderUserId });
            
            CreateTable(
                "dbo.QueryCategoryQueries",
                c => new
                    {
                        QueryCategory_Id = c.Int(nullable: false),
                        Query_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.QueryCategory_Id, t.Query_Id })
                .ForeignKey("dbo.QueryCategories", t => t.QueryCategory_Id, cascadeDelete: true)
                .ForeignKey("dbo.Queries", t => t.Query_Id, cascadeDelete: true)
                .Index(t => t.QueryCategory_Id)
                .Index(t => t.Query_Id);
            
            CreateTable(
                "dbo.webpages_RolesUser",
                c => new
                    {
                        webpages_Roles_RoleId = c.Int(nullable: false),
                        User_ID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.webpages_Roles_RoleId, t.User_ID })
                .ForeignKey("dbo.webpages_Roles", t => t.webpages_Roles_RoleId, cascadeDelete: true)
                .ForeignKey("dbo.Users", t => t.User_ID, cascadeDelete: true)
                .Index(t => t.webpages_Roles_RoleId)
                .Index(t => t.User_ID);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.MessagingLogs", "PhoneNumber", "dbo.OtherSystemUserNumbers");
            DropForeignKey("dbo.OptionBPlusFacilities", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.MTUHA_ReportSectionDetails", "SectionId", "dbo.MTUHA_ReportSections");
            DropForeignKey("dbo.MTUHA_ReportSections", "MTUHAReportId", "dbo.MTUHA_Reports");
            DropForeignKey("dbo.ModemAssociatedCellNumbers", "ModemSettingNo", "dbo.ModemSettings");
            DropForeignKey("dbo.MobilePhoneOperators", "MCC", "dbo.MobileContryCode");
            DropForeignKey("dbo.MergingReports", "SourceReportId", "dbo.Report");
            DropForeignKey("dbo.ReportDataMerging", "MergeId", "dbo.ReportMerge");
            DropForeignKey("dbo.MergingReports", "MergeId", "dbo.ReportMerge");
            DropForeignKey("dbo.MergingReports", "DestinationReportId", "dbo.Report");
            DropForeignKey("dbo.Translations", "LangID", "dbo.Languages");
            DropForeignKey("dbo.ExcelTemplateSheets", "TemplateID", "dbo.ExcelTemplateReport");
            DropForeignKey("dbo.ExcelTemplateCells", "SheetID", "dbo.ExcelTemplateSheets");
            DropForeignKey("dbo.ExcelTemplateCellExtras", "CellID", "dbo.ExcelTemplateCells");
            DropForeignKey("dbo.ErrMsgSMS", "KnownReportingErrorId", "dbo.KnownReportingErrors");
            DropForeignKey("dbo.ANCForm_HudhurioLaKwanza", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.ANCForm_HudhurioLaKwanza", "MetadataId", "dbo.ANCFormMetadata");
            DropForeignKey("dbo.ANCFormMetadata", "InputMethodId", "dbo.DataInputMethod");
            DropForeignKey("dbo.ANCForm_Malaria", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.ANCForm", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.ANCForm", "MetadataId", "dbo.ANCFormMetadata");
            DropForeignKey("dbo.ANCForm_PMTCT", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.TestingAndCounselingDatas", "UserId", "dbo.Users");
            DropForeignKey("dbo.webpages_RolesUser", "User_ID", "dbo.Users");
            DropForeignKey("dbo.webpages_RolesUser", "webpages_Roles_RoleId", "dbo.webpages_Roles");
            DropForeignKey("dbo.Users", "SupportingPartnerId", "dbo.SupportingPartners");
            DropForeignKey("dbo.QueryCategories", "User_ID", "dbo.Users");
            DropForeignKey("dbo.Queries", "User_ID", "dbo.Users");
            DropForeignKey("dbo.Queries", "UpdatedByUserId", "dbo.Users");
            DropForeignKey("dbo.Queries", "QueryTypeId", "dbo.QueryTypes");
            DropForeignKey("dbo.QueryParameters", "QueryId", "dbo.Queries");
            DropForeignKey("dbo.QueryCategories", "UpdatedByUserId", "dbo.Users");
            DropForeignKey("dbo.QueryCategoryQueries", "Query_Id", "dbo.Queries");
            DropForeignKey("dbo.QueryCategoryQueries", "QueryCategory_Id", "dbo.QueryCategories");
            DropForeignKey("dbo.QueryCategories", "CreatedByUserId", "dbo.Users");
            DropForeignKey("dbo.Queries", "DeletedByUserId", "dbo.Users");
            DropForeignKey("dbo.Queries", "CreatedByUserId", "dbo.Users");
            DropForeignKey("dbo.Users", "AccessLevelID", "dbo.AccessLevels");
            DropForeignKey("dbo.TestingAndCounselingDatas", "TimeframeId", "dbo.Timeframes");
            DropForeignKey("dbo.TestingAndCounselingDatas", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.TestingAndCounselingDatas", "CounselingAndTestingId", "dbo.TestingAndCounselings");
            DropForeignKey("dbo.CDCTargets", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.Facilities", "SupportingPartnerId", "dbo.SupportingPartners");
            DropForeignKey("dbo.OtherSystemsFacilityDetails", "SystemId", "dbo.OtherSystems");
            DropForeignKey("dbo.OtherSystemsFacilityDetails", "InternalFacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.LDForms", "WatotoWaliozaliwaMmoja_9id", "dbo.LDForm_WatotoWaliozaliwaMmoja");
            DropForeignKey("dbo.LDForm_WatotoWaliozaliwaMmoja", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.LDForm_WatotoWaliozaliwaMmoja", "MetadataId", "dbo.ANCFormMetadata");
            DropForeignKey("dbo.LDForms", "WatotoWaliozaliwaMapacha_10id", "dbo.LDForm_WatotoWaliozaliwaMapacha");
            DropForeignKey("dbo.LDForm_WatotoWaliozaliwaMapacha", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.LDForm_WatotoWaliozaliwaMapacha", "MetadataId", "dbo.ANCFormMetadata");
            DropForeignKey("dbo.LDForms", "WatotoWaliosaidiwaKupumua_11id", "dbo.LDForm_WatotoWaliosaidiwaKupumua");
            DropForeignKey("dbo.LDForm_WatotoWaliosaidiwaKupumua", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.LDForm_WatotoWaliosaidiwaKupumua", "MetadataId", "dbo.ANCFormMetadata");
            DropForeignKey("dbo.LDForms", "TaarifaYaWaliojifungua_2id", "dbo.LDForm_TaarifaYaWaliojifungua");
            DropForeignKey("dbo.LDForm_TaarifaYaWaliojifungua", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.LDForm_TaarifaYaWaliojifungua", "MetadataId", "dbo.ANCFormMetadata");
            DropForeignKey("dbo.LDForms", "PMTCT_8id", "dbo.LDForm_PMTCT");
            DropForeignKey("dbo.LDForm_PMTCT", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.LDForm_PMTCT", "MetadataId", "dbo.ANCFormMetadata");
            DropForeignKey("dbo.LDForms", "NjiaYaKujifungua_3id", "dbo.LDForm_NjiaYaKujifungua");
            DropForeignKey("dbo.LDForm_NjiaYaKujifungua", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.LDForm_NjiaYaKujifungua", "MetadataId", "dbo.ANCFormMetadata");
            DropForeignKey("dbo.LDForms", "MatatizoKablaYaKujifungua_4id", "dbo.LDForm_MatatizoKablaYaKujifungua");
            DropForeignKey("dbo.LDForm_MatatizoKablaYaKujifungua", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.LDForm_MatatizoKablaYaKujifungua", "MetadataId", "dbo.ANCFormMetadata");
            DropForeignKey("dbo.LDForms", "MatatizoBaadaYaKujifungua_6id", "dbo.LDForm_MatatizoBaadaYaKujifungua");
            DropForeignKey("dbo.LDForm_MatatizoBaadaYaKujifungua", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.LDForm_MatatizoBaadaYaKujifungua", "MetadataId", "dbo.ANCFormMetadata");
            DropForeignKey("dbo.LDForms", "EmOC_7id", "dbo.LDForm_EmOC");
            DropForeignKey("dbo.LDForms", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.LDForms", "MetadataId", "dbo.ANCFormMetadata");
            DropForeignKey("dbo.LDForm_EmOC", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.LDForm_EmOC", "MetadataId", "dbo.ANCFormMetadata");
            DropForeignKey("dbo.Facilities", "FacilityType", "dbo.FacilityType");
            DropForeignKey("dbo.SMSReminderTracker", "ReportID", "dbo.Report");
            DropForeignKey("dbo.SMSReminderTracker", "FacCode", "dbo.Facilities");
            DropForeignKey("dbo.ReportDataLocations", "RepID", "dbo.Report");
            DropForeignKey("dbo.ReportBusinessRules", "RepID", "dbo.Report");
            DropForeignKey("dbo.ReportData", "RepID", "dbo.Report");
            DropForeignKey("dbo.ReportData", "ReceivedSMSNo", "dbo.ReceivedSMs");
            DropForeignKey("dbo.ReceivedSMs", "RepID", "dbo.Report");
            DropForeignKey("dbo.ReceivedSMs", "FacCode", "dbo.Facilities");
            DropForeignKey("dbo.ExpectedReports", "ReportID", "dbo.Report");
            DropForeignKey("dbo.AutoReminderReportMessageTemplates", "ReportId", "dbo.Report");
            DropForeignKey("dbo.ExpectedReports", "FacCode", "dbo.Facilities");
            DropForeignKey("dbo.District", "RegionNo", "dbo.Region");
            DropForeignKey("dbo.AutoReminderRegions", "RegionId", "dbo.Region");
            DropForeignKey("dbo.Facilities", "District", "dbo.District");
            DropForeignKey("dbo.AutoReminderDistricts", "DistrictId", "dbo.District");
            DropForeignKey("dbo.AutoReminderFacilities", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.ANCForm_VidokezoVyaHatari", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.ANCForm", "VidokezoVyaHatari_4id", "dbo.ANCForm_VidokezoVyaHatari");
            DropForeignKey("dbo.ANCForm_VidokezoVyaHatari", "MetadataId", "dbo.ANCFormMetadata");
            DropForeignKey("dbo.ANCForm", "PMTCT_5id", "dbo.ANCForm_PMTCT");
            DropForeignKey("dbo.ANCForm_PMTCT", "MetadataId", "dbo.ANCFormMetadata");
            DropForeignKey("dbo.ANCForm", "Malaria_6id", "dbo.ANCForm_Malaria");
            DropForeignKey("dbo.ANCForm", "HudhurioLaKwanza_2id", "dbo.ANCForm_HudhurioLaKwanza");
            DropForeignKey("dbo.ANCForm_Malaria", "MetadataId", "dbo.ANCFormMetadata");
            DropIndex("dbo.webpages_RolesUser", new[] { "User_ID" });
            DropIndex("dbo.webpages_RolesUser", new[] { "webpages_Roles_RoleId" });
            DropIndex("dbo.QueryCategoryQueries", new[] { "Query_Id" });
            DropIndex("dbo.QueryCategoryQueries", new[] { "QueryCategory_Id" });
            DropIndex("dbo.MessagingLogs", new[] { "PhoneNumber" });
            DropIndex("dbo.OptionBPlusFacilities", new[] { "FacilityCode" });
            DropIndex("dbo.MTUHA_ReportSectionDetails", new[] { "SectionId" });
            DropIndex("dbo.MTUHA_ReportSections", new[] { "MTUHAReportId" });
            DropIndex("dbo.ModemAssociatedCellNumbers", new[] { "ModemSettingNo" });
            DropIndex("dbo.MobilePhoneOperators", new[] { "MCC" });
            DropIndex("dbo.ReportDataMerging", new[] { "MergeId" });
            DropIndex("dbo.ReportMerge", new[] { "Name" });
            DropIndex("dbo.MergingReports", "IX_MergingReports");
            DropIndex("dbo.Translations", new[] { "LangID" });
            DropIndex("dbo.ExcelTemplateSheets", new[] { "TemplateID" });
            DropIndex("dbo.ExcelTemplateCellExtras", new[] { "CellID" });
            DropIndex("dbo.ExcelTemplateCells", new[] { "SheetID" });
            DropIndex("dbo.ErrMsgSMS", new[] { "KnownReportingErrorId" });
            DropIndex("dbo.QueryParameters", new[] { "QueryId" });
            DropIndex("dbo.QueryCategories", new[] { "User_ID" });
            DropIndex("dbo.QueryCategories", new[] { "UpdatedByUserId" });
            DropIndex("dbo.QueryCategories", new[] { "CreatedByUserId" });
            DropIndex("dbo.Queries", new[] { "User_ID" });
            DropIndex("dbo.Queries", new[] { "DeletedByUserId" });
            DropIndex("dbo.Queries", new[] { "UpdatedByUserId" });
            DropIndex("dbo.Queries", new[] { "CreatedByUserId" });
            DropIndex("dbo.Queries", new[] { "QueryTypeId" });
            DropIndex("dbo.Queries", new[] { "InternalName" });
            DropIndex("dbo.Users", new[] { "SupportingPartnerId" });
            DropIndex("dbo.Users", new[] { "AccessLevelID" });
            DropIndex("dbo.TestingAndCounselingDatas", new[] { "UserId" });
            DropIndex("dbo.TestingAndCounselingDatas", new[] { "CounselingAndTestingId" });
            DropIndex("dbo.TestingAndCounselingDatas", new[] { "TimeframeId" });
            DropIndex("dbo.TestingAndCounselingDatas", new[] { "FacilityCode" });
            DropIndex("dbo.CDCTargets", new[] { "FacilityCode" });
            DropIndex("dbo.OtherSystemsFacilityDetails", new[] { "InternalFacilityCode" });
            DropIndex("dbo.OtherSystemsFacilityDetails", new[] { "SystemId" });
            DropIndex("dbo.LDForm_WatotoWaliozaliwaMmoja", new[] { "FacilityCode" });
            DropIndex("dbo.LDForm_WatotoWaliozaliwaMmoja", new[] { "MetadataId" });
            DropIndex("dbo.LDForm_WatotoWaliozaliwaMapacha", new[] { "FacilityCode" });
            DropIndex("dbo.LDForm_WatotoWaliozaliwaMapacha", new[] { "MetadataId" });
            DropIndex("dbo.LDForm_WatotoWaliosaidiwaKupumua", new[] { "FacilityCode" });
            DropIndex("dbo.LDForm_WatotoWaliosaidiwaKupumua", new[] { "MetadataId" });
            DropIndex("dbo.LDForm_TaarifaYaWaliojifungua", new[] { "FacilityCode" });
            DropIndex("dbo.LDForm_TaarifaYaWaliojifungua", new[] { "MetadataId" });
            DropIndex("dbo.LDForm_PMTCT", new[] { "FacilityCode" });
            DropIndex("dbo.LDForm_PMTCT", new[] { "MetadataId" });
            DropIndex("dbo.LDForm_NjiaYaKujifungua", new[] { "FacilityCode" });
            DropIndex("dbo.LDForm_NjiaYaKujifungua", new[] { "MetadataId" });
            DropIndex("dbo.LDForm_MatatizoKablaYaKujifungua", new[] { "FacilityCode" });
            DropIndex("dbo.LDForm_MatatizoKablaYaKujifungua", new[] { "MetadataId" });
            DropIndex("dbo.LDForm_MatatizoBaadaYaKujifungua", new[] { "FacilityCode" });
            DropIndex("dbo.LDForm_MatatizoBaadaYaKujifungua", new[] { "MetadataId" });
            DropIndex("dbo.LDForms", new[] { "FacilityCode" });
            DropIndex("dbo.LDForms", new[] { "MetadataId" });
            DropIndex("dbo.LDForms", new[] { "WatotoWaliosaidiwaKupumua_11id" });
            DropIndex("dbo.LDForms", new[] { "WatotoWaliozaliwaMapacha_10id" });
            DropIndex("dbo.LDForms", new[] { "WatotoWaliozaliwaMmoja_9id" });
            DropIndex("dbo.LDForms", new[] { "PMTCT_8id" });
            DropIndex("dbo.LDForms", new[] { "EmOC_7id" });
            DropIndex("dbo.LDForms", new[] { "MatatizoBaadaYaKujifungua_6id" });
            DropIndex("dbo.LDForms", new[] { "MatatizoKablaYaKujifungua_4id" });
            DropIndex("dbo.LDForms", new[] { "NjiaYaKujifungua_3id" });
            DropIndex("dbo.LDForms", new[] { "TaarifaYaWaliojifungua_2id" });
            DropIndex("dbo.LDForm_EmOC", new[] { "FacilityCode" });
            DropIndex("dbo.LDForm_EmOC", new[] { "MetadataId" });
            DropIndex("dbo.SMSReminderTracker", new[] { "ReportID" });
            DropIndex("dbo.SMSReminderTracker", new[] { "FacCode" });
            DropIndex("dbo.ReportDataLocations", new[] { "RepID" });
            DropIndex("dbo.ReportBusinessRules", new[] { "RepID" });
            DropIndex("dbo.ReportData", new[] { "RepID" });
            DropIndex("dbo.ReportData", new[] { "ReceivedSMSNo" });
            DropIndex("dbo.ReceivedSMs", new[] { "RepID" });
            DropIndex("dbo.ReceivedSMs", new[] { "FacCode" });
            DropIndex("dbo.AutoReminderReportMessageTemplates", new[] { "ReportId" });
            DropIndex("dbo.ExpectedReports", new[] { "ReportID" });
            DropIndex("dbo.ExpectedReports", new[] { "FacCode" });
            DropIndex("dbo.AutoReminderRegions", new[] { "RegionId" });
            DropIndex("dbo.AutoReminderDistricts", new[] { "DistrictId" });
            DropIndex("dbo.District", new[] { "RegionNo" });
            DropIndex("dbo.AutoReminderFacilities", new[] { "FacilityCode" });
            DropIndex("dbo.ANCForm_VidokezoVyaHatari", new[] { "FacilityCode" });
            DropIndex("dbo.ANCForm_VidokezoVyaHatari", new[] { "MetadataId" });
            DropIndex("dbo.Facilities", new[] { "SupportingPartnerId" });
            DropIndex("dbo.Facilities", new[] { "FacilityType" });
            DropIndex("dbo.Facilities", new[] { "District" });
            DropIndex("dbo.ANCForm_PMTCT", new[] { "FacilityCode" });
            DropIndex("dbo.ANCForm_PMTCT", new[] { "MetadataId" });
            DropIndex("dbo.ANCForm", new[] { "FacilityCode" });
            DropIndex("dbo.ANCForm", new[] { "MetadataId" });
            DropIndex("dbo.ANCForm", new[] { "Malaria_6id" });
            DropIndex("dbo.ANCForm", new[] { "PMTCT_5id" });
            DropIndex("dbo.ANCForm", new[] { "VidokezoVyaHatari_4id" });
            DropIndex("dbo.ANCForm", new[] { "HudhurioLaKwanza_2id" });
            DropIndex("dbo.ANCForm_Malaria", new[] { "FacilityCode" });
            DropIndex("dbo.ANCForm_Malaria", new[] { "MetadataId" });
            DropIndex("dbo.ANCFormMetadata", new[] { "InputMethodId" });
            DropIndex("dbo.ANCForm_HudhurioLaKwanza", new[] { "FacilityCode" });
            DropIndex("dbo.ANCForm_HudhurioLaKwanza", new[] { "MetadataId" });
            DropTable("dbo.webpages_RolesUser");
            DropTable("dbo.QueryCategoryQueries");
            DropTable("dbo.webpages_OAuthMembership");
            DropTable("dbo.webpages_Membership");
            DropTable("dbo.SysSettings");
            DropTable("dbo.StockStatus");
            DropTable("dbo.SMSReminders");
            DropTable("dbo.SMSLog");
            DropTable("dbo.SendSMSQueue");
            DropTable("dbo.ReportChartIndicators");
            DropTable("dbo.PresetChartsIndicators");
            DropTable("dbo.PresetCharts");
            DropTable("dbo.OtherSystemUserNumbers");
            DropTable("dbo.MessagingLogs");
            DropTable("dbo.OptionBPlusFacilities");
            DropTable("dbo.MTUHA_ReportSectionDetails");
            DropTable("dbo.MTUHA_ReportSections");
            DropTable("dbo.MTUHA_Reports");
            DropTable("dbo.ModemSettings");
            DropTable("dbo.ModemAssociatedCellNumbers");
            DropTable("dbo.MobilePhoneOperators");
            DropTable("dbo.MobileContryCode");
            DropTable("dbo.ReportDataMerging");
            DropTable("dbo.ReportMerge");
            DropTable("dbo.MergingReports");
            DropTable("dbo.Translations");
            DropTable("dbo.Languages");
            DropTable("dbo.ExcelTemplateReport");
            DropTable("dbo.ExcelTemplateSheets");
            DropTable("dbo.ExcelTemplateCellExtras");
            DropTable("dbo.ExcelTemplateCells");
            DropTable("dbo.KnownReportingErrors");
            DropTable("dbo.ErrMsgSMS");
            DropTable("dbo.ComparisonType");
            DropTable("dbo.CalendarHolidays");
            DropTable("dbo.BlockedNumbers");
            DropTable("dbo.Assistance");
            DropTable("dbo.ApprovedSMSCells");
            DropTable("dbo.DataInputMethod");
            DropTable("dbo.webpages_Roles");
            DropTable("dbo.QueryTypes");
            DropTable("dbo.QueryParameters");
            DropTable("dbo.QueryCategories");
            DropTable("dbo.Queries");
            DropTable("dbo.Users");
            DropTable("dbo.Timeframes");
            DropTable("dbo.TestingAndCounselings");
            DropTable("dbo.TestingAndCounselingDatas");
            DropTable("dbo.CDCTargets");
            DropTable("dbo.SupportingPartners");
            DropTable("dbo.OtherSystems");
            DropTable("dbo.OtherSystemsFacilityDetails");
            DropTable("dbo.LDForm_WatotoWaliozaliwaMmoja");
            DropTable("dbo.LDForm_WatotoWaliozaliwaMapacha");
            DropTable("dbo.LDForm_WatotoWaliosaidiwaKupumua");
            DropTable("dbo.LDForm_TaarifaYaWaliojifungua");
            DropTable("dbo.LDForm_PMTCT");
            DropTable("dbo.LDForm_NjiaYaKujifungua");
            DropTable("dbo.LDForm_MatatizoKablaYaKujifungua");
            DropTable("dbo.LDForm_MatatizoBaadaYaKujifungua");
            DropTable("dbo.LDForms");
            DropTable("dbo.LDForm_EmOC");
            DropTable("dbo.FacilityType");
            DropTable("dbo.SMSReminderTracker");
            DropTable("dbo.ReportDataLocations");
            DropTable("dbo.ReportBusinessRules");
            DropTable("dbo.ReportData");
            DropTable("dbo.ReceivedSMs");
            DropTable("dbo.AutoReminderReportMessageTemplates");
            DropTable("dbo.Report");
            DropTable("dbo.ExpectedReports");
            DropTable("dbo.AutoReminderRegions");
            DropTable("dbo.Region");
            DropTable("dbo.AutoReminderDistricts");
            DropTable("dbo.District");
            DropTable("dbo.AutoReminderFacilities");
            DropTable("dbo.ANCForm_VidokezoVyaHatari");
            DropTable("dbo.Facilities");
            DropTable("dbo.ANCForm_PMTCT");
            DropTable("dbo.ANCForm");
            DropTable("dbo.ANCForm_Malaria");
            DropTable("dbo.ANCFormMetadata");
            DropTable("dbo.ANCForm_HudhurioLaKwanza");
            DropTable("dbo.AccessLevels");
        }
#else
        public override void Up()
        { 

        }

        public override void Down()
        {

        }
#endif
    }
}
